package com.mxpio.erp.technology.service.impl;

import com.mxpio.erp.common.enums.CommonEnums;
import com.mxpio.erp.common.technology.entity.ProcessInfo;
import com.mxpio.erp.common.technology.entity.ProdTecRoutProc;
import com.mxpio.erp.common.technology.service.ProcessInfoService;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.jpa.query.Criteria;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ProcessInfoServiceImpl extends BaseServiceImpl<ProcessInfo> implements ProcessInfoService {
    @Override
    @Transactional(readOnly = true)
    public Page<ProcessInfo> getUnrelatedProcPage(String productItemCode, Pageable pageAble, Criteria criteria) {
        return JpaUtil
                .linq(ProcessInfo.class)
                .notExists(ProdTecRoutProc.class)
                    .equalProperty("processCode", "processCode")
                    .equal("routId", productItemCode)
                    //工序段为空
                    .isNull("procGroupCode")
                .end()
                .equal("status", CommonEnums.YesNo.YES.getCode())
                .where(criteria)
                .paging(pageAble);
    }
}
